﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Karbel.RFID
{
    public enum Location
    {
        A1= 0,
        A2 = 1,
        A3 = 2,
        A4 = 3
    }

    public class Movement
    {
        public Movement(Location location, DateTime date)
        {
            Location = location;
            Date = date;
        }

        int duration = -1;
        public int Duration
        {
            get { return duration; }
            set { duration = value; }
        }

        int signalCount = -1;
        public int SignalCount
        {
            get { return signalCount; }
            set { signalCount = value; }
        }

        public string DurationInfo
        {
            get
            {
                if (Duration == -1)
                {
                    return CurrentLocationString;
                }
                else if (Duration < 2)
                {
                    return Duration.ToString() + " second";
                }
                else
                {
                    return Duration.ToString() + " seconds";
                }
            }
        }

        Location location;
        public Location Location
        {
            get { return location; }
            set { location = value; }
        }

        DateTime date;
        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }

        public static string CurrentLocationString = "Current Location";

        public override string ToString()
        {
            return Date.ToString("dd.MM.yyyy HH:mm:ss") + ":" + Location.ToString() + " . " + DurationInfo;
        }
    }

    public class Tag
    {
        int id;
        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            foreach (Movement movement in Movements)
            {
                sb.Append(Id + " (" + movement + ") " + Environment.NewLine);
            }
            return sb.ToString();
        }

        private List<Movement> movements = new List<Movement>();
        public List<Movement> Movements
        {
            get { return movements; }
            set { movements = value; }
        }

        public Movement LastMovement
        {
            get {
                return Movements[Movements.Count - 1];
            }
        }
    }
}
